package com.xdf.whiteaccount.controller;

import com.xdf.whiteaccount.enums.ResponseEnum;
import com.xdf.whiteaccount.utils.BeanUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.xdf.whiteaccount.entity.ResponseResult;
import java.util.List;
import java.util.Map;

import com.xdf.whiteaccount.entity.CpBillfh;
import com.xdf.whiteaccount.service.CpBillfhService;

/**
 * @Description : 自动生成的控制层
 * @Author : 张柯
 * @Date : 2021-06-25 09:44:52
 */
@Api(tags = "")
@CrossOrigin
@RestController
@RequestMapping("/cpBillfh")
public class CpBillfhController {

    @Autowired
    private CpBillfhService service;

    /**
     * @Description : 选择新增
     * @Return : ResponseResult<Void>
     * @Author : 张柯
     * @Date : 2021-06-25 09:44:52
     */
    @ApiOperation(value = "选择新增", httpMethod = "POST", notes = "自动生成的新增方法")
    @RequestMapping(value = "/insertSelective", method = RequestMethod.POST)
    public ResponseResult<Void> insertSelective(CpBillfh record) throws Exception {
        service.insertSelective(record);
        return ResponseResult.<Void>builder().success(true).message(ResponseEnum.OK.getName()).build();
    }

    /**
     * @Description : 批量新增
     * @Return : ResponseResult<Void>
     * @Author : 张柯
     * @Date : 2021-06-25 09:44:52
     */
    @ApiOperation(value = "批量新增", httpMethod = "POST", notes = "自动生成的新增方法")
    @RequestMapping(value = "/multiInsert", method = RequestMethod.POST)
    public ResponseResult<Void> multiInsert(@RequestBody List<CpBillfh> list) throws Exception {
        service.multiInsert(list);
        return ResponseResult.<Void>builder().success(true).message(ResponseEnum.OK.getName()).build();
    }

    /**
     * @Description : 选择修改
     * @Return : CpBillfh
     * @Author : 张柯
     * @Date : 2021-06-25 09:44:52
     */
    @ApiOperation(value = "选择修改", httpMethod = "PUT", notes = "自动生成的修改方法")
    @RequestMapping(value = "/updateSelective", method = RequestMethod.POST)
    public ResponseResult<Void> updateSelective(CpBillfh record) throws Exception {
        service.updateByPrimaryKeySelective(record);
        return ResponseResult.<Void>builder().success(true).message(ResponseEnum.OK.getName()).build();
    }

    /**
     * @Description : 批量修改
     * @Return : CpBillfh
     * @Author : 张柯
     * @Date : 2021-06-25 09:44:52
     */
    @ApiOperation(value = "批量修改", httpMethod = "POST", notes = "自动生成的修改方法")
    @RequestMapping(value = "/multiUpdate", method = RequestMethod.POST)
    public ResponseResult<Void> multiUpdate(@RequestBody List<CpBillfh> list) throws Exception {
        service.multiUpdate(list);
        return ResponseResult.<Void>builder().success(true).message(ResponseEnum.OK.getName()).build();
    }

    /**
     * @Description : 根据主键查询
     * @Return : CpBillfh
     * @Author : 张柯
     * @Date : 2021-06-25 09:44:52
     */
    @ApiOperation(value = "根据主键查询", httpMethod = "GET", notes = "自动生成的查询方法")
    @RequestMapping(value = "/queryByPk/{id}", method = RequestMethod.GET)
    public CpBillfh selectByPrimaryKey(@PathVariable("id") Integer id) throws Exception {
        if (id == null) return null;
        return service.selectByPrimaryKey(id);
    }

    /**
     * @Description : 查询方法
     * @Return : java.utils.List
     * @Author : 张柯
     * @Date : 2021-06-25 09:44:52
     */
    @ApiOperation(value = "查询方法", httpMethod = "GET", notes = "自动生成的查询方法")
    @RequestMapping(value = "/listQuery", method = RequestMethod.GET)
    public List<CpBillfh> query(CpBillfh record) throws Exception {
        return service.listQuery(record);
    }

    @ApiOperation(value = "查询方法", httpMethod = "POST", notes = "自动生成的查询方法")
    @RequestMapping(value = "/insert8ShelvesList", method = RequestMethod.POST)
    public List<CpBillfh> insert8ShelvesList(@RequestBody List<String> shelveList) throws Exception {
        return service.insert8ShelvesList(shelveList);
    }

    @ApiOperation(value = "erp端在库存页面选择货架号后发货", httpMethod = "POST", notes = "自动生成的查询方法")
    @RequestMapping(value = "/insert8ShelvesListClient", method = RequestMethod.POST)
    public List<CpBillfh> insert8ShelvesListClient(@RequestBody Map<String, Object> params) throws Exception {
        Map fhdMap = (Map)params.get("fhd");
        CpBillfh fhd = CpBillfh.builder().build();
        BeanUtils.mapToBean(fhdMap, fhd);
        List<String> shelveList = (List<String>)params.get("shelveList");
        return service.insert8ShelvesList(fhd, shelveList);
    }

    @ApiOperation(value = "PDA通过扫描两种二维码发货（单匹二维码+货架二维码）", httpMethod = "POST", notes = "自动生成的查询方法")
    @RequestMapping(value = "/insert8JrkIdListClient", method = RequestMethod.POST)
    public List<CpBillfh> insert8JrkIdListClient(@RequestBody Map<String, Object> params) throws Exception {
        Map fhdMap = (Map)params.get("fhd");
        CpBillfh fhd = CpBillfh.builder().build();
        BeanUtils.mapToBean(fhdMap, fhd);
        List<Integer> jrkIdList = (List<Integer>)params.get("jrkIdList");
        return service.insert8JrkIdList(fhd, jrkIdList);
    }

    @ApiOperation(value = "根据主键作废发货", httpMethod = "POST", notes = "自动生成的查询方法")
    @RequestMapping(value = "/setVoid", method = RequestMethod.POST)
    public Integer setVoid(@RequestBody Map<String,Integer> params) throws Exception {
        Integer id = params.get("id");
        return service.setVoid(id);
    }
}